package daytrader.types;

import java.util.Date;

public class Hold {
        private static int counter = 0;
	public int id;                // The id of the purchase
	public Stock stock;            // The stock bought.
	public PurchaseType type;      // The type of the purchase
	public double price;           // The price when purchased
	public int amount;             // The amount purchased
	public Date time;              // The time of the purchase.
	public double exec_price;      // The execution price of an hold option.
	public Date exec_date;         // The execution date of an hold option.

	public Hold(Stock stock, int amount, double price) {
	        this.id = Hold.getID();
		this.stock = stock;
		this.amount = amount;
		this.price = price;
		this.type = PurchaseType.Stock;
		this.time = new Date();
	}

	public static synchronized int getID() {
	        Hold.counter += 1;
	        return Hold.counter;
	}

        public String company_name() {
           return this.stock.company_name();
        }

        public Sector sector() {
           return this.stock.sector();
        }

        public boolean equals(Object aThat) {
           if (this == aThat) return true;
           if (!(aThat instanceof Hold )) return false;
           Hold that = (Hold) aThat;
           return that.id == this.id;
        }
}

